package 高级Java;
  public class MethodName {   
	  /**
	   * java代码获取当前类类名方法名:
	   * @param args
	   */
	  public static void main(String[] args) { 
      MethodName methodName = new MethodName();   
		  String clazz = Thread.currentThread() .getStackTrace()[1].getClassName();
		  String method = Thread.currentThread() .getStackTrace()[1].getMethodName();
		  System.out.println("class name: " + clazz + " Method Name " + method); 
		  methodName.anotherMethod(); 
		  }   
		  private void anotherMethod() { 
		  String clazz = this.getClass().getName(); 
		  String method = Thread.currentThread() .getStackTrace()[1].getMethodName(); 
		  System.out.println("class name: " + clazz + " Method Name " + method);   
	 }  
}